home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / include / xpm / xpm.h
Encoding:
C/C++ Source or Header  |  1995-07-03  |  11.8 KB  |  379 lines

  1. /* Copyright 1990-93 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * xpm.h:                                                                      *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Include file                                                               *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #ifndef XPM_h
  12. #define XPM_h
  13.  
  14. /*
  15.  * first some identification numbers:
  16.  * the following revision numbers is determined with the following rule:
  17.  * SO Major number = LIB minor version number.
  18.  * SO Minor number = LIB sub-minor version number.
  19.  * e.g: Xpm version 3.2f
  20.  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
  21.  *      thus we have XpmVersion = 2 and XpmRevision = 6
  22.  *      which gives  SOXPMLIBREV = 2.6
  23.  */
  24. #define XpmFormat 3
  25. #define XpmVersion 3
  26. #define XpmRevision 0
  27.  
  28. #ifndef XPM_NUMBERS
  29.  
  30. #ifdef VMS
  31. #include "decw$include:Xlib.h"
  32. #include "decw$include:Xutil.h"
  33. #else
  34. #include <X11/Xlib.h>
  35. #include <X11/Xutil.h>
  36. #endif
  37.  
  38. /* let's define Pixel if it is not done yet */
  39. #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
  40. typedef unsigned long Pixel;        /* Index into colormap */
  41. #define PIXEL_ALREADY_TYPEDEFED
  42. #endif
  43.  
  44. /* Return ErrorStatus codes:
  45.  * null     if full success
  46.  * positive if partial success
  47.  * negative if failure
  48.  */
  49.  
  50. #define XpmColorError    1
  51. #define XpmSuccess       0
  52. #define XpmOpenFailed   -1
  53. #define XpmFileInvalid  -2
  54. #define XpmNoMemory     -3
  55. #define XpmColorFailed  -4
  56.  
  57. /* the following should help people wanting to use their own functions */
  58. #define XpmFree(ptr) free(ptr)
  59.  
  60. typedef struct {
  61.     char *name;                /* Symbolic color name */
  62.     char *value;            /* Color value */
  63.     Pixel pixel;            /* Color pixel */
  64. }      XpmColorSymbol;
  65.  
  66. typedef struct {
  67.     char *name;                /* name of the extension */
  68.     unsigned int nlines;        /* number of lines in this extension */
  69.     char **lines;            /* pointer to the extension array of
  70.                      * strings */
  71. }      XpmExtension;
  72.  
  73. typedef struct {
  74.     unsigned long valuemask;        /* Specifies which attributes are
  75.                      * defined */
  76.  
  77.     Visual *visual;            /* Specifies the visual to use */
  78.     Colormap colormap;            /* Specifies the colormap to use */
  79.     unsigned int depth;            /* Specifies the depth */
  80.     unsigned int width;            /* Returns the width of the created
  81.                      * pixmap */
  82.     unsigned int height;        /* Returns the height of the created
  83.                      * pixmap */
  84.     unsigned int x_hotspot;        /* Returns the x hotspot's
  85.                      * coordinate */
  86.     unsigned int y_hotspot;        /* Returns the y hotspot's
  87.                      * coordinate */
  88.     unsigned int cpp;            /* Specifies the number of char per
  89.                      * pixel */
  90.     Pixel *pixels;            /* List of used color pixels */
  91.     unsigned int npixels;        /* Number of pixels */
  92.     XpmColorSymbol *colorsymbols;    /* Array of color symbols to
  93.                      * override */
  94.     unsigned int numsymbols;        /* Number of symbols */
  95.     char *rgb_fname;            /* RGB text file name */
  96.     unsigned int nextensions;        /* number of extensions */
  97.     XpmExtension *extensions;        /* pointer to array of extensions */
  98.  
  99.     /* Color Allocation Directives */
  100.     unsigned int exactColors;        /* Only use exact colors for visual */
  101.     unsigned int closeness;        /* Allowable RGB deviation */
  102.     unsigned int red_closeness;        /* Allowable red deviation */
  103.     unsigned int green_closeness;    /* Allowable green deviation */
  104.     unsigned int blue_closeness;    /* Allowable blue deviation */
  105.     int color_key;            /* Use colors from this color set */
  106.  
  107. }      XpmAttributes;
  108.  
  109. /* Xpm attribute value masks bits */
  110. #define XpmVisual       (1L<<0)
  111. #define XpmColormap       (1L<<1)
  112. #define XpmDepth       (1L<<2)
  113. #define XpmSize           (1L<<3)    /* width & height */
  114. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  115. #define XpmCharsPerPixel   (1L<<5)
  116. #define XpmColorSymbols       (1L<<6)
  117. #define XpmRgbFilename       (1L<<7)
  118. /************************************ there was
  119. #define XpmInfos       (1L<<8) all infos members
  120. */
  121. #define XpmExtensions      (1L<<10)
  122.  
  123. #define XpmReturnPixels       (1L<<9)
  124. /************************************ there was
  125. #define XpmReturnInfos       XpmInfos
  126. */
  127. #define XpmReturnExtensions XpmExtensions
  128.  
  129. #define XpmExactColors     (1L<<11)
  130. #define XpmCloseness       (1L<<12)
  131. #define XpmRGBCloseness       (1L<<13)
  132. #define XpmColorKey       (1L<<14)
  133.  
  134. /*
  135.  * color keys for visual type, they must fit along with the number key of
  136.  * each related element in xpmColorKeys[] defined in xpmP.h
  137.  */
  138. #define XPM_MONO    2
  139. #define XPM_GREY4    3
  140. #define XPM_GRAY4    3
  141. #define XPM_GREY     4
  142. #define XPM_GRAY     4
  143. #define XPM_COLOR    5
  144.  
  145.  
  146. typedef struct {
  147.     char *string;        /* characters string */
  148.     char *symbolic;        /* symbolic name */
  149.     char *m_color;        /* monochrom default */
  150.     char *g4_color;        /* 4 level grayscale default */
  151.     char *g_color;        /* other level grayscale default */
  152.     char *c_color;        /* color default */
  153. }      XpmColor;
  154.  
  155. typedef struct {
  156.     unsigned int width;        /* image width */
  157.     unsigned int height;    /* image height */
  158.     unsigned int cpp;        /* number of characters per pixel */
  159.     unsigned int ncolors;    /* number of colors */
  160.     XpmColor *colorTable;    /* list of related colors */
  161.     unsigned int *data;        /* image data */
  162. }      XpmImage;
  163.  
  164. typedef struct {
  165.     char *hints_cmt;        /* Comment of the hints section */
  166.     char *colors_cmt;        /* Comment of the colors section */
  167.     char *pixels_cmt;        /* Comment of the pixels section */
  168. }      XpmInfos;
  169.  
  170.  
  171. /*
  172.  * minimal portability layer between ansi and KR C
  173.  */
  174.  
  175. /* forward declaration of functions with prototypes */
  176.  
  177. #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
  178.  /* ANSI || C++ */
  179. #define FUNC(f, t, p) extern t f p
  180. #define LFUNC(f, t, p) static t f p
  181. #else                    /* K&R */
  182. #define FUNC(f, t, p) extern t f()
  183. #define LFUNC(f, t, p) static t f()
  184. #endif                    /* end of K&R */
  185.  
  186.  
  187. /*
  188.  * functions declarations
  189.  */
  190.  
  191. #ifdef __cplusplus
  192. extern "C" {
  193. #endif
  194.  
  195.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  196.                     Drawable d,
  197.                     char **data,
  198.                     Pixmap *pixmap_return,
  199.                     Pixmap *shapemask_return,
  200.                     XpmAttributes *attributes));
  201.  
  202.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  203.                     char ***data_return,
  204.                     Pixmap pixmap,
  205.                     Pixmap shapemask,
  206.                     XpmAttributes *attributes));
  207.  
  208.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  209.                     Drawable d,
  210.                     char *filename,
  211.                     Pixmap *pixmap_return,
  212.                     Pixmap *shapemask_return,
  213.                     XpmAttributes *attributes));
  214.  
  215.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  216.                        char *filename,
  217.                        Pixmap pixmap,
  218.                        Pixmap shapemask,
  219.                        XpmAttributes *attributes));
  220.  
  221.     FUNC(XpmCreateImageFromData, int, (Display *display,
  222.                        char **data,
  223.                        XImage **image_return,
  224.                        XImage **shapemask_return,
  225.                        XpmAttributes *attributes));
  226.  
  227.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  228.                        char ***data_return,
  229.                        XImage *image,
  230.                        XImage *shapeimage,
  231.                        XpmAttributes *attributes));
  232.  
  233.     FUNC(XpmReadFileToImage, int, (Display *display,
  234.                    char *filename,
  235.                    XImage **image_return,
  236.                    XImage **shapeimage_return,
  237.                    XpmAttributes *attributes));
  238.  
  239.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  240.                       char *filename,
  241.                       XImage *image,
  242.                       XImage *shapeimage,
  243.                       XpmAttributes *attributes));
  244.  
  245.     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
  246.                      char *buffer,
  247.                      XImage **image_return,
  248.                      XImage **shapemask_return,
  249.                      XpmAttributes *attributes));
  250.  
  251.     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
  252.                       Drawable d,
  253.                       char *buffer,
  254.                       Pixmap *pixmap_return,
  255.                       Pixmap *shapemask_return,
  256.                       XpmAttributes *attributes));
  257.  
  258.     FUNC(XpmCreateBufferFromImage, int, (Display *display,
  259.                      char **buffer_return,
  260.                      XImage *image,
  261.                      XImage *shapeimage,
  262.                      XpmAttributes *attributes));
  263.  
  264.     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
  265.                       char **buffer_return,
  266.                       Pixmap pixmap,
  267.                       Pixmap shapemask,
  268.                       XpmAttributes *attributes));
  269.  
  270.     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
  271.     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
  272.  
  273.     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
  274.     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
  275.  
  276.     FUNC(XpmAttributesSize, int, ());
  277.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  278.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
  279.                    int nextensions));
  280.     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
  281.     FUNC(XpmFreeXpmInfos, void, (XpmInfos *infos));
  282.     FUNC(XpmGetErrorString, char *, (int errcode));
  283.  
  284.     /* XpmImage functions */
  285.     FUNC(XpmReadFileToXpmImage, int, (char *filename,
  286.                       XpmImage *image,
  287.                       XpmAttributes *attributes,
  288.                       XpmInfos *infos));
  289.  
  290.     FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
  291.                      XpmImage *image,
  292.                      XpmAttributes *attributes,
  293.                      XpmInfos *infos));
  294.  
  295.     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
  296.                         Drawable d,
  297.                         XpmImage *image,
  298.                         Pixmap *pixmap_return,
  299.                         Pixmap *shapemask_return,
  300.                         XpmAttributes *attributes));
  301.  
  302.     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
  303.                        XpmImage *image,
  304.                        XImage **image_return,
  305.                        XImage **shapeimage_return,
  306.                        XpmAttributes *attributes));
  307.  
  308.     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
  309.                        XImage *image,
  310.                        XImage *shapeimage,
  311.                        XpmImage *xpmimage,
  312.                        XpmAttributes *attributes));
  313.  
  314.     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
  315.                         Pixmap pixmap,
  316.                         Pixmap shapemask,
  317.                         XpmImage *xpmimage,
  318.                         XpmAttributes *attributes));
  319.  
  320.     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
  321.                       XpmImage *image,
  322.                       XpmAttributes *attributes));
  323.  
  324.     FUNC(XpmCreateXpmImageFromData, int, (char **data,
  325.                       XpmImage *image,
  326.                       XpmAttributes *attributes));
  327.  
  328.     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
  329.                         XpmImage *image,
  330.                         XpmAttributes *attributes,
  331.                         XpmInfos *infos));
  332.  
  333.     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
  334.                         XpmImage *image,
  335.                         XpmAttributes *attributes,
  336.                         XpmInfos *infos));
  337.  
  338. #ifdef __cplusplus
  339. }                    /* for C++ V2.0 */
  340. #endif
  341.  
  342.  
  343. /* backward compatibility */
  344.  
  345. /* for version 3.0c */
  346. #define XpmPixmapColorError  XpmColorError
  347. #define XpmPixmapSuccess     XpmSuccess
  348. #define XpmPixmapOpenFailed  XpmOpenFailed
  349. #define XpmPixmapFileInvalid XpmFileInvalid
  350. #define XpmPixmapNoMemory    XpmNoMemory
  351. #define XpmPixmapColorFailed XpmColorFailed
  352.  
  353. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  354.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  355. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  356.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  357.  
  358. /* for version 3.0b */
  359. #define PixmapColorError  XpmColorError
  360. #define PixmapSuccess     XpmSuccess
  361. #define PixmapOpenFailed  XpmOpenFailed
  362. #define PixmapFileInvalid XpmFileInvalid
  363. #define PixmapNoMemory    XpmNoMemory
  364. #define PixmapColorFailed XpmColorFailed
  365.  
  366. #define ColorSymbol XpmColorSymbol
  367.  
  368. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  369.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  370. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  371.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  372. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  373.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  374. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  375.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  376.  
  377. #endif /* XPM_NUMBERS */
  378. #endif
  379.